/*
 * Copyright the original author or authors.
 */
package com.derbysoft.core.support;

import org.hibernate.ScrollableResults;


/**
 * <code>ScrollableResultsTotalCountGetter</code> 使用 {@link ScrollableResults} 获得总记录数
 *
 * @author snowway
 * @since 2009-2-18
 */
public class ScrollableResultsTotalCountGetter implements TotalcountGetter {

    private ScrollableResults scrollableResults;

    public ScrollableResultsTotalCountGetter(ScrollableResults scrollableResults) {
        this.scrollableResults = scrollableResults;
    }

    @Override
    public int count() {
        scrollableResults.last();
        return scrollableResults.getRowNumber() + 1;
    }
}
